import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 0
 * Date: 2023-03-09
 * Time: 10:05
 */
public class Test {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count = 3;
        while(count != 0) {
            System.out.println("请输入你的密码：");
            String password = scanner.nextLine();
            if(password.equals("123")) {
                System.out.println("密码正确");
                break;
            }else {
                count--;
                System.out.println("密码错误，你还有"+count+"次机会");
            }
        }
    }

    public static void main6(String[] args) {
        int[] array = new int[]{1,2,3,4,5};
        System.out.println("avg"+"="+avg(array));
    }

    public static int avg(int[] a) {
        int sum = 0;
        for (int i = 0; i < a.length; i++) {
            sum += a[i];
        }
        return sum/a.length;
    }

    public static void main5(String[] args) {
        int[] array = new int[]{1,2,3,4,5};
        System.out.println("sum"+"="+sum(array));
    }

    public static int sum(int[] a) {
        int sum = 0;
        for (int i = 0; i < a.length; i++) {
            sum += a[i];
        }
        return sum;
    }

    public static void main4(String[] args) {
        int[] array = {1,2,3};
        for (int x:array) {
            System.out.print(x+" ");
        }
        System.out.println();
        transform(array);
    }

    public static void transform(int[] a) {
        for (int i = 0; i < 3; i++) {
            a[i] *= 2;
        }
        for (int x:a) {
            System.out.print(x+" ");
        }
    }

    public static void main3(String[] args) {
        int[] array = new int[10];
        for (int i = 0; i < 10; i++) {
            array[i] = i+1;
        }
        printArray(array);
    }

    public static void printArray(int[] a) {
        for (int x:a) {
            System.out.print(x+" ");
        }
    }

    public static void main2(String[] args) {
        int[] array = {1,2,3,4,5};
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i]+" ");
        }
        System.out.println();
        System.out.println(array.length);
        for (int x:array) {
            System.out.print(x+" ");
        }
        System.out.println();
        System.out.println("=======");
        System.out.println(Arrays.toString(array));

    }

    public static void main1(String[] args) {
        int[] array1 = {1,2,3,4,5};
        int[] array2 = new int[5];
        int[] array3 = new int[]{1,2,3,4,5};
        int[] array4;
        array4 = new int[]{1,2,3,4,5};
        boolean[] flag = new boolean[5];
        String[] string = new String[5];
        char[] chars = new char[5];
    }
}
